<%
# ユーザのブックマーク一覧表示
# :locals => { :pages, :login_user_id }
%>

<style type="text/css">
div.entry_space {
  border: 1px solid silver;
  width: 98%;
  margin: auto;
  text-align: left;
  margin-top: 3px;
  margin-bottom: 3px;
  position: relative;
  font-size: 10px;
}
div.entry_space div.entry_line {
  margin: 0;
  border-bottom: 1px dashed silver;
  padding: 0px;
}
</style>

<div id="contents_container">
<div id="contents_left">

<div class="box_space">
  <div class="box_space_title"><%= icon_tag 'find' -%>検索</div>
  <div class="box_space_body">
  <% form_tag({:controller => 'user', :action => 'bookmark', :user_id => params[:user_id]}, {:method => 'get'}) do -%>
  <%= text_field_tag('keyword', params[:keyword], :size=>'12') %>
  <%= submit_tag '検索' %>
  <% end %>
  <div class="desc">タイトル、コメントが検索対象となります</div>
  </div>
  <div class="box_space_bottom"></div>
</div><!-- box_space -->

<% @bookmark_types = [
   {:name => 'スター', :type => 'star', :icon => 'star'},
   {:name => 'ユーザ', :type => 'user', :icon => 'user'},
   {:name => 'ブログ/BBS', :type => 'page', :icon => 'report_link'},
   {:name => 'インターネット', :type => 'internet', :icon => 'world_link'} ] %>

<div class="box_space">
  <div class="box_space_title"><%= icon_tag 'text_list_bullets' -%>種類</div>
  <div class="box_space_body">
    <ul>
      <% @bookmark_types.each do |bookmark_type| -%>
      <li style='<%= "background-color: yellow" if params[:type] == bookmark_type[:type] -%>'>
      <%= icon_tag bookmark_type[:icon] -%><%= link_to bookmark_type[:name], {:controller => 'user', :action=>'bookmark', :type=>bookmark_type[:type], :user_id => params[:user_id]} -%>
      </li>
      <% end -%>
    </ul>
  </div>
  <div class="box_space_bottom"><%= link_to "[選択をキャンセル]", {:controller => 'user', :action=>'bookmark', :user_id => params[:user_id]} -%></div>
</div><!-- box_space -->

<div class="box_space">
  <div class="box_space_title"><%= icon_tag 'tag_blue' -%>タグ</div>
  <div class="box_space_body">
    <% tag_cloud @tags do |name, count, css_class| %>
    <% if params[:category] == name -%><span style="background-color: yellow;"><% end -%>
      <%= link_to name, {:controller => 'user', :action=>'bookmark', :category=>name, :user_id => params[:user_id]}, :class => css_class -%>
      <% if params[:category] == name -%></span><% end -%>
    <span style="color: silver; font-size: 10px;">(<%= count -%>)</span>
    <% end %>
  </div>
  <div class="box_space_bottom"><%= link_to "[選択をキャンセル]", {:controller => 'user', :action=>'bookmark', :user_id => params[:user_id]} -%></div>
</div><!-- box_space -->

</div><!-- contents_left -->
<div id="contents_right">

<% if pages and pages.item_count > 0 -%>

<div class="navi"><%= page_link pages -%></div>

  <% for comment in @bookmark_comments %>

  <div class="entry_space" id="bookmark_comment_<%= comment.id -%>">
    <div class="entry_line" style="font-size: 90%; background-color: #ffeeff;">
      <%=h comment.created_on.strftime("%Y年%m月%d日") %>
      <span style="font-size:10px"><%= link_to("[他のユーザ:#{comment.bookmark.bookmark_comments_count}人]", encode_bookmark_url(comment.bookmark.url)) %></span>
    </div>
    <div class="entry_line" style="font-size: 12px;">
      <% if params[:user_id] == login_user_id -%>
      <% elem_id = "bookmark_comment_stared_#{comment.id}" -%>
      <span id="<%= elem_id -%>"><%= render :partial => "stared", :locals => {:bookmark_comment => comment} -%></span>
      <% end -%>
      <%= link_to_bookmark_url(comment.bookmark,comment.bookmark.title) %>
    </div>
    <div style="text-align: right; font-size: 90%;">
      <span style="color: blue;"><%=h comment.tags %></span><%=h comment.comment %>
        <% if login_user_id == comment.user_id %>
        <%= link_to(icon_tag('tag_blue_edit', :alt => '編集'), {:controller => "bookmark", :action => "edit", :url => comment.bookmark.url, :title => comment.bookmark.title, :dummy => '.html'}, {:class => "nyroModal"}) %>
        <%= link_to_function icon_tag('tag_blue_delete', :alt => '削除'),"if (confirm('本当に削除しますか')) { var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST';f.action = get_action_value(this.href, #{comment.id}); f.submit();}",:href => url_for(:controller =>'bookmark', :action =>'destroy'), :title => "削除"  %>
      <script  language='javascript' type='text/javascript'>
        function get_action_value(href, comment_id){
          return  href +'/' + escape('<%= comment.bookmark.get_encode_url %>') + '?comment_id=' + comment_id;
        }
      </script>
       <% end %>
    </div>
  </div>

  <% end %>

<div class="navi"><%= page_link pages -%></div>

<% end %>

</div><!-- contents_right -->

<div id="contents_bottom">
</div><!-- contents_bottom -->

</div><!-- contents_container -->


